(function () { if (window.fakhamaGamesAdded) return; window.fakhamaGamesAdded = true; function addGames() { if (document.getElementById("fakhama-extra-games")) return; const items = [...document.querySelectorAll("button,a,div,span")] .filter(el => { const t = el.textContent.trim(); return t === "يوكام لودو" || t === "إكس أو"; }); if (!items.length) return; const target = items.sort( (a,b) => a.textContent.length - b.textContent.length )[0]; const menu = target.parentElement; if (!menu) return; const box = document.createElement("div"); box.id = "fakhama-extra-games"; const games = [ ["🧠 لعبة الذاكرة", "#9250a8", "memory"], ["🔢 تخمين الرقم", "#299e62", "guess"], ["✊ حجر وورقة ومقص", "#d05c50", "rps"], ["🎯 تحدي الذكاء", "#c49a36", "quiz"] ]; games.forEach(([name,color,type]) => { const btn = document.createElement("button"); btn.textContent = name; btn.style.cssText = "display:block;width:100%;padding:18px 8px;margin:5px 0;" + "border:1px solid #555;border-radius:6px;color:white;" + "font-size:20px;font-weight:bold;cursor:pointer;background:" + color; btn.onclick = () => openGame(type); box.appendChild(btn); }); menu.appendChild(box); } function openGame(type) { document.getElementById("fg-game-window")?.remove(); const win = document.createElement("div"); win.id = "fg-game-window"; win.dir = "rtl"; win.style.cssText = "position:fixed;inset:0;z-index:999999;background:#fff;" + "padding:20px;text-align:center;font-family:Arial;overflow:auto"; let html = ""; if (type === "guess") { html = `

🔢 تخمين الرقم

خمن رقماً من 1 إلى 20

`; } if (type === "rps") { html = `

✊ حجر وورقة ومقص

`; } if (type === "memory") { html = `

🧠 لعبة الذاكرة

اعثر على الصور المتشابهة

`; } if (type === "quiz") { html = `

🎯 تحدي الذكاء

كم يساوي 7 × 8 ؟

`; } win.innerHTML = `
${html} `; document.body.appendChild(win); win.querySelector("#fg-close").onclick = () => win.remove(); if (type === "guess") { let secret = Math.floor(Math.random()*20)+1; win.querySelector("#fg-check").onclick = () => { let n = Number(win.querySelector("#fg-input").value); let r = win.querySelector("#fg-result"); if (!Number.isInteger(n) || n<1 || n>20) { r.textContent = "اختر رقماً من 1 إلى 20"; } else if (n===secret) { r.textContent = "🏆 أحسنت! فزت"; secret = Math.floor(Math.random()*20)+1; } else { r.textContent = n { btn.onclick = () => { const user = btn.dataset.r; const bot = ["حجر","ورقة","مقص"][Math.floor(Math.random()*3)]; const won = (user==="حجر"&&bot==="مقص") || (user==="ورقة"&&bot==="حجر") || (user==="مقص"&&bot==="ورقة"); win.querySelector("#fg-result").textContent = "اختيارك "+user+" - الكمبيوتر "+bot+" : "+ (user===bot?"تعادل":won?"فزت 🎉":"حاول مرة ثانية"); }; }); } if (type === "quiz") { win.querySelectorAll("[data-q]").forEach(btn => { btn.onclick = () => { win.querySelector("#fg-result").textContent = btn.dataset.q==="56" ? "إجابة صحيحة 🏆" : "حاول مرة ثانية"; }; }); } if (type === "memory") { const symbols = ["🍎","🍋","⭐","🚗","🍎","🍋","⭐","🚗"]; symbols.sort(() => Math.random()-.5); let first=null, locked=false, count=0; symbols.forEach(symbol => { const b=document.createElement("button"); b.textContent="❔"; b.style.cssText="height:55px;font-size:25px"; b.onclick=()=>{ if(locked||b.dataset.done||b===first)return; b.textContent=symbol; if(!first){first=b;return;} if(first.textContent===b.textContent){ first.dataset.done="1";b.dataset.done="1"; first=null;count++; if(count===4)win.querySelector("#fg-result").textContent="فزت 🏆"; }else{ locked=true; const old=first; setTimeout(()=>{ old.textContent="❔";b.textContent="❔"; first=null;locked=false; },700); } }; win.querySelector("#fg-cards").appendChild(b); }); } } addGames(); const observer = new MutationObserver(addGames); observer.observe(document.body,{childList:true,subtree:true}); })();